﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dominion.Core
{
    public static class Tools
    {
        public static void Foreach(this int i, Action<int> action)
        {
            var values = Enumerable.Range(0, i).ToList();
            values.ForEach(action);
        }


        public static void Shuffle<T>(this IList<T> list)
        {
            Random rng = new Random();
            int n = list.Count;
            while (n > 1)
            {
                n--;
                int k = rng.Next(n + 1);
                T value = list[k];
                list[k] = list[n];
                list[n] = value;
            }
        }

        public static void Push<T>(this IList<T> list, T item)
        {
            list.Add(item);
        }

        public static T Pop<T>(this IList<T> list)
        {
            T item = list.Last();
            list.Remove(item);
            return item;
        }


     

    }
}
